Paul Fox and Robert Lipe include tracks and routes in GPX <bounds> info.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 14 Nov 2005 14:28:43 +0000 (14:28 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 14 Nov 2005 14:28:43 +0000 (14:28 +0000)
20 files changed:
gpsbabel/Makefile
gpsbabel/defs.h
gpsbabel/gpx.c
gpsbabel/reference/coastexp.ref
gpsbabel/reference/gdb-sample.gpx
gpsbabel/reference/igc1_gpx.out
gpsbabel/reference/igc2_gpx.out
gpsbabel/reference/route/compegps-rte.gpx
gpsbabel/reference/route/cst-sample.gpx
gpsbabel/reference/route/mag_pdb-sample.gpx
gpsbabel/reference/route/msroute-sample.gpx
gpsbabel/reference/route/nmn4-sample.gpx
gpsbabel/reference/route/tef_xml.sample.gpx
gpsbabel/reference/track/compegps-trk.gpx
gpsbabel/reference/track/ignrando-sample.gpx
gpsbabel/reference/track/pathaway.gpx
gpsbabel/reference/track/stmwpp-track.gpx
gpsbabel/reference/track/trackfilter.gpx
gpsbabel/reference/track/vitosmt_t.gpx
gpsbabel/waypt.c

index 5632e6dc8b8f4a2ebb2236d8cee52567bf47609e..f85e8ef7c67516fdd8694a6d191110e2b8e503b2 100644 (file)
@@ -1,7 +1,7 @@
 
 VERSU=1_2_8
 VERSD=1.2.8
-RELEASE=-beta11082005
+RELEASE=-beta11102005
 VERSIONU=$(VERSU)$(RELEASE)
 VERSIOND=$(VERSD)$(RELEASE)
 
index 97b47b13257c1c0cdcf2cb5333cb04be424d25c0..fdb1de893fe957cad2bfe1a8d820c742ca4bdaec 100644 (file)
@@ -355,6 +355,9 @@ waypoint * waypt_new(void);
 void waypt_del (waypoint *);
 void waypt_free (waypoint *);
 void waypt_disp_all(waypt_cb);
+void waypt_init_bounds(bounds *bounds);
+int waypt_bounds_valid(bounds *bounds);
+void waypt_add_to_bounds(bounds *bounds, const waypoint *waypointp);
 void waypt_compute_bounds(bounds *);
 void waypt_flush(queue *);
 void waypt_flush_all(void);
index 8abe43c5299ea97fbda487d2cb9d228ccd0d7ea8..b6cf88acd2b0a4e94d05ecdcb029e894500be5c8 100644 (file)
@@ -58,6 +58,8 @@ static char *suppresswhite = NULL;
 static char *urlbase = NULL;
 static route_head *trk_head;
 static route_head *rte_head;
+/* used for bounds calculation on output */
+static bounds all_bounds;
 
 static format_specific_data **fs_ptr;
 
@@ -196,7 +198,6 @@ static void
 gpx_rm_from_global(gpx_global_entry *ge)
 {
        queue *elem, *tmp;
-       gpx_global_entry * gep;
 
        QUEUE_FOR_EACH(&ge->queue, elem, tmp) {
                gpx_global_entry *g = (gpx_global_entry *) dequeue(elem);
@@ -1562,12 +1563,34 @@ void gpx_route_pr()
        route_disp_all(gpx_route_hdr, gpx_route_tlr, gpx_route_disp);
 }
 
+static void
+gpx_waypt_bound_calc(const waypoint *waypointp)
+{
+       waypt_add_to_bounds(&all_bounds, waypointp);
+}
+
+static void
+gpx_write_bounds(void)
+{
+       waypt_init_bounds(&all_bounds);
+
+       waypt_disp_all(gpx_waypt_bound_calc);
+       route_disp_all(NULL, NULL, gpx_waypt_bound_calc);
+       track_disp_all(NULL, NULL, gpx_waypt_bound_calc);
+
+       if (waypt_bounds_valid(&all_bounds)) {
+               fprintf(ofd, "<bounds minlat=\"%0.9f\" minlon =\"%0.9f\" "
+                              "maxlat=\"%0.9f\" maxlon=\"%0.9f\" />\n",
+                              all_bounds.min_lat, all_bounds.min_lon, 
+                              all_bounds.max_lat, all_bounds.max_lon);
+       }
+}
+
 static void
 gpx_write(void)
 {
        time_t now = 0;
        int short_length;
-       bounds bounds;
 
        gpx_wversion_num = strtod(gpx_wversion, NULL) * 10;
 
@@ -1616,13 +1639,7 @@ gpx_write(void)
        xml_write_time( ofd, now, "time" );
        gpx_write_gdata(&gpx_global->keywords, "keywords");
 
-       waypt_compute_bounds(&bounds);
-       if (bounds.max_lat  > -360) {
-               fprintf(ofd, "<bounds minlat=\"%0.9f\" minlon =\"%0.9f\" "
-                              "maxlat=\"%0.9f\" maxlon=\"%0.9f\" />\n",
-                              bounds.min_lat, bounds.min_lon, 
-                              bounds.max_lat, bounds.max_lon);
-       }
+       gpx_write_bounds();
 
        if (gpx_wversion_num > 10) {    
                fprintf(ofd, "</metadata>\n");
index 4c5dad94cdf296e045f848523599deac05833e86..492e32f3e634b40b5eeca8f914feb512ff2c1b61 100755 (executable)
@@ -6,7 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
-<bounds minlat="34.019184000" minlon ="-122.441589000" maxlat="37.229349000" maxlon="-120.438209000" />
+<bounds minlat="34.019184000" minlon ="-122.605838000" maxlat="37.819339000" maxlon="-120.438209000" />
 <wpt lat="37.229349000" lon="-122.441589000">
 <time>2004-11-05T21:13:00Z</time>
   <name>PESCDR01</name>
index 90a54c69ea53cf362f2029007d3a241753ae7694..727d5faac10af021a5263d209d79f17d4b43d597 100644 (file)
@@ -6,7 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
-<bounds minlat="50.492618987" minlon ="12.105448823" maxlat="51.314520836" maxlon="12.435919438" />
+<bounds minlat="50.476993863" minlon ="12.090926170" maxlat="51.315169176" maxlon="12.510294914" />
 <wpt lat="50.877340632" lon="12.433888670">
   <name>3</name>
   <cmt>B93</cmt>
index 759ad215257c7b560e0aac85376502b6cf775d2e..12c7d967d7341399e9583846c3dd3f5f53d7432e 100644 (file)
@@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
+<bounds minlat="-30.765600000" minlon ="150.602533333" maxlat="-30.675433333" maxlon="150.725983333" />
 <rte>
   <name>0001</name>
   <desc>IGCDATE000000: </desc>
index 1a5fb96edf4a4c4365ea827dde2d19d82286b54f..3b724ea1128a008f75152f925a8da0351b7c803a 100644 (file)
@@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
+<bounds minlat="51.118766667" minlon ="-2.920450000" maxlat="54.118683333" maxlon="-0.293533333" />
 <rte>
   <name>0001</name>
   <desc>IGCDATE160701: 500KTri</desc>
index 1ac52bc5ebb1d6f07ae2ee051a343acdaf10bb5b..ed1b3c79cac9ecd997b29624f5ce368d6464d6ce 100644 (file)
@@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
+<bounds minlat="45.754467000" minlon ="11.449617000" maxlat="45.789383000" maxlon="11.553583000" />
 <rte>
   <name>test</name>
   <rtept lat="45.789383000" lon="11.553583000">
index 68a3f46923f6cc6aa5e5b43e1bb7f3aba49d752b..82ca4ce636675366ddbc107c7a081b4c9c7b446c 100644 (file)
@@ -6,7 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
-<bounds minlat="47.545980000" minlon ="2.665770000" maxlat="47.565210000" maxlon="2.713690000" />
+<bounds minlat="47.543230000" minlon ="2.664750000" maxlat="47.565520000" maxlon="2.722340000" />
 <wpt lat="47.565210000" lon="2.713690000">
   <ele>1272.900000</ele>
 <time>2005-06-18T08:53:36Z</time>
index 109bd39508039391f4ba863f3df75793b5c3cfb8..8a23e61db446d14ed91169f1271a39ff73fc8a02 100644 (file)
@@ -6,7 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
-<bounds minlat="49.469250000" minlon ="11.046166667" maxlat="49.935527778" maxlon="11.476083333" />
+<bounds minlat="49.445861111" minlon ="11.044861111" maxlat="49.935944444" maxlon="11.481583333" />
 <wpt lat="49.718250000" lon="11.066416667">
   <name>Jägersburg in Forchheim geradeaus weiter auf Eisenbahnstrasse</name>
   <cmt>Jägersburg in Forchheim geradeaus weiter auf Eisenbahnstrasse</cmt>
index 677d4d87a224fb6379ace6c2a7c1f781b81c10d0..ccffa0d73f25a309e61ae50761673d9cc3edcf65 100644 (file)
@@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
+<bounds minlat="50.497369766" minlon ="12.135772705" maxlat="50.628690720" maxlon="12.998456955" />
 <rte>
   <rtept lat="50.497369766" lon="12.135772705">
     <name>Plauen</name>
index 58ae1174723c8b9108a9bc963df0e4f614eece54..0473d9546950790dd4092bbd386d35341ef0dff8 100644 (file)
@@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
+<bounds minlat="49.021900000" minlon ="11.587670000" maxlat="50.494250000" maxlon="12.675630000" />
 <rte>
   <rtept lat="50.494250000" lon="12.107270000">
     <name>RPT001</name>
index 201b69e12c155c30ffab555f2da4f86890377c3a..f9e6870958ecb224683eb1f82f41e9366b34fee0 100644 (file)
@@ -6,7 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
-<bounds minlat="50.271540000" minlon ="11.642810000" maxlat="50.756270000" maxlon="12.671250000" />
+<bounds minlat="50.268830000" minlon ="11.640990000" maxlat="50.756540000" maxlon="12.696920000" />
 <wpt lat="50.362350000" lon="11.903730000">
   <name>in Zedtwitz halb rechts halten auf B2 Hofer Strasse</name>
   <cmt>B2 Hofer Strasse</cmt>
index a291deefa1b91ebe748f3a4fde85c59c7659a55d..06456e1d7745e0d57a93818af7ec1dbf7c6da5eb 100644 (file)
@@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
+<bounds minlat="51.312750000" minlon ="12.409350000" maxlat="51.314650000" maxlon="12.414983333" />
 <trk>
   <name>ACTIVE LOG 006</name>
 <trkseg>
index 0147b2a0380cc288ebcfc4e8dbd5ee28d0e78629..298cdda3a3e7328979f1d81ebe07c011910e4396 100644 (file)
@@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
+<bounds minlat="45.660805000" minlon ="6.365717000" maxlat="45.667271000" maxlon="6.372394000" />
 <trk>
   <desc>20050719 Mar Tamié ind 2 VTT Sem Europ</desc>
 <trkseg>
index 72552ca80a7882915b9d31aaa3eb40b3535ef1cf..dcad06f9fbb2f31f78df298222cbe451253575a0 100644 (file)
@@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
+<bounds minlat="50.319399833" minlon ="11.700503833" maxlat="50.496254000" maxlon="12.138562167" />
 <trk>
   <name>20050116_Fahrradtour Gerd</name>
 <trkseg>
index ba8b2e0b2944dd814c6ffa7e77e8fcc8aa6c3cee..f6204f68f28f21e898c5213f54ab2cee661bffb4 100644 (file)
@@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
+<bounds minlat="45.177499900" minlon ="4.634587200" maxlat="45.187113000" maxlon="4.660729700" />
 <trk>
 <trkseg>
 <trkpt lat="45.187113000" lon="4.660729700">
index 7bd01cc053ef5dfaf3e8cb5315ea43ef7bacc511..567b34cc689693943c67761886135354639f1378 100644 (file)
@@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
+<bounds minlat="30.045517000" minlon ="-91.610567000" maxlat="30.062783000" maxlon="-91.589750000" />
 <trk>
   <name>LOG-20020525</name>
 <trkseg>
index f692d17b242c32bc43cf4944c533ddeedb7e67a8..ff68ffa68826b2758293a58acbd0917a01d34185 100644 (file)
@@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://www.topografix.com/GPX/1/0"
 xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
 <time>1970-01-01T00:00:00Z</time>
+<bounds minlat="45.458204984" minlon ="-75.770526640" maxlat="45.497519984" maxlon="-75.684934974" />
 <trk>
 <trkseg>
 <trkpt lat="45.460366651" lon="-75.767939974">
index bf5a30dc510e7a482a5b46000981d84571192d37..bf1af9880417ae3bebf12abe228891ed422099ec 100644 (file)
@@ -208,6 +208,40 @@ waypt_disp_all(waypt_cb cb)
        }
 }
 
+void
+waypt_init_bounds(bounds *bounds)
+{
+       /* Set data out of bounds so that even one waypoint will reset */
+       bounds->max_lat = -9999;
+       bounds->max_lon = -9999;
+       bounds->min_lat = 9999;
+       bounds->min_lon = 9999;
+}
+
+int
+waypt_bounds_valid(bounds *bounds)
+{
+       /* Returns true if bb has any 'real' data in it */
+       return bounds->max_lat > -9999;
+}
+
+/*
+ * Recompund bounding box based on new position point.
+ */
+void 
+waypt_add_to_bounds(bounds *bounds, const waypoint *waypointp)
+{
+       if (waypointp->latitude > bounds->max_lat)
+               bounds->max_lat = waypointp->latitude;
+       if (waypointp->longitude > bounds->max_lon)
+               bounds->max_lon = waypointp->longitude;
+       if (waypointp->latitude < bounds->min_lat)
+               bounds->min_lat = waypointp->latitude;
+       if (waypointp->longitude < bounds->min_lon)
+               bounds->min_lon = waypointp->longitude;
+}
+
+
 /*
  *  Makes another pass over the data to compute bounding
  *  box data and populates bounding box information.
@@ -219,22 +253,11 @@ waypt_compute_bounds(bounds *bounds)
        queue *elem, *tmp;
        waypoint *waypointp;
 
-       /* Set data out of bounds so that even one waypoint will reset */
-       bounds->max_lat = -9999;
-       bounds->max_lon = -9999;
-       bounds->min_lat = 9999;
-       bounds->min_lon = 9999;
+       waypt_init_bounds(bounds);
 
        QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
                waypointp = (waypoint *) elem;
-               if (waypointp->latitude > bounds->max_lat)
-                       bounds->max_lat = waypointp->latitude;
-               if (waypointp->longitude > bounds->max_lon)
-                       bounds->max_lon = waypointp->longitude;
-               if (waypointp->latitude < bounds->min_lat)
-                       bounds->min_lat = waypointp->latitude;
-               if (waypointp->longitude < bounds->min_lon)
-                       bounds->min_lon = waypointp->longitude;
+               waypt_add_to_bounds(bounds, waypointp);
        }
 }